import router from "./index";
import {getToken} from "@/utils/auth";
import {adminInfo} from "@/store/customer/inedx";
const whiteList = ['/login','/home','/main','/tags','/category','/post'] // no redirect whitelist

router.beforeEach((to, from, next) => {
    let hasToken = !!getToken();
    console.log(hasToken)
    if (whiteList.indexOf(to.path) !== -1) {
        next()
    } else {
        if (hasToken) {
            if (to.path === '/login') {
                //直接去往管理页面
                next('/admin')
            } else {
                //这里可以处理一些页面配置信息
                next()
            }
        } else {
            next(`/login?redirect=${to.path}`)
        }
    }
})